<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增工作计划</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/bootstrap.js" type="text/javascript"></script>
    <script src="js/jsrender.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            var today = new Date()
            var nowDate = today.getFullYear() +
                "-" + (today.getMonth()+1<10?"0"+(today.getMonth()+1):today.getMonth()+1)+
                "-" + (today.getDate()<10?"0"+today.getDate():today.getDate())
            $("#workDate").val(nowDate)

            $("form").submit(function(){
                // alert($("form").serialize())
                $.ajax({
                    url: GC.bctx + "workPlan/insert",
                    type:"POST",
                    data:$("form").serialize(),
                    headers: {"Authorization": localStorage.getItem("token")},
                    success:function(r){
                        if(r.successed){
                            //修改成功，转向显示所有部门页面
                            alert(r.message)
                            window.location.href="workPlans.html"
                        }else{
                            //修改失败，显示失败信息
                            alert(r.message)
                        }
                    }
                })
                return false
            })

            $("#nurseID").blur(function(){
                // alert($("#nurseID").val())
                if($("#nurseID").val()==""){
                    $("#nurseName").val("")
                    return false;
                }
                if($("#nurseID").val()!=""){
                    if(isNaN($("#nurseID").val())){
                        alert("护士编号必须为纯数字!")
                        $("#nurseName").val("")
                        return false;
                    }
                    // alert("进入非空")
                    $.ajax({
                        url: GC.bctx + "workPlan/checkNurseID/" + $("#nurseID").val(),
                        type: "GET",
                        headers: {"Authorization": localStorage.getItem("token")},
                        success: function (r) {
                            if (r.successed) {
                                //修改成功，转向显示所有部门页面
                                $("#nurseName").val(r.data)
                            } else {
                                //修改失败，显示失败信息
                                alert(r.message)
                                $("#nurseName").val("")
                            }
                        }
                    })
                }
            })


        })
    </script>
</head>
<body>
<div class="container-fluid">
    <h1>新增工作计划</h1>
    <hr/>
    <form>
        <table>
            <tr>
                <td >工作计划日期：</td>
                <td><input type="date" id="workDate" name="workDate"/></td>
                <td><span class="c-r">*</span></td>
            </tr>
            <tr>
                <td>护士编号：</td>
                <td><input id="nurseID" class="form-control" name="nurseID" type="text"/></td>
                <td><span class="c-r">*</span></td>
            </tr>
            <tr>
                <td>护士名：</td>
                <td><input id="nurseName" class="form-control" name="nurseName" type="text" readonly="readonly"/></td>
            </tr>
            <tr>
                <td>早班状态：</td>
                <td>
                    <label>上班</label>
                    <input id="workMorningOn" name="workMorning" value="true" type="radio"/>
                    <label>休息</label>
                    <input id="workMorningOff" name="workMorning" value="false" type="radio"/>
                </td>
            </tr>
            <tr>
                <td>早班状态：</td>
                <td>
                    <label>上班</label>
                    <input id="workAfternoonOn"  name="workAfternoon" value="true" type="radio"/>
                    <label>休息</label>
                    <input id="workAfternoonOff"  name="workAfternoon" value="false" type="radio"/>
                </td>
            </tr>
            <tr>
                <td>晚班状态：</td>
                <td>
                    <label>上班</label>
                    <input id="workEveningOn"  name="workEvening" value="true" type="radio"/>
                    <label>休息</label>
                    <input id="workEveningOff"  name="workEvening" value="false" type="radio"/>
                </td>
            </tr>
            <tr>
                <td colspan="3" class="text-center">
                    <input type="submit" value="保存"/>
                    <input type="reset" value="重置"/>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>